package com.ruoyi.labsafety.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labsafety.domain.LabSafetyCheckIndex;
import com.ruoyi.labsafety.service.ILabSafetyCheckIndexService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安全检查模板Controller
 * 
 * @author ruoyi
 * @date 2022-03-06
 */
@RestController
@RequestMapping("/labsafety/labsafetyCheckIndex")
public class LabSafetyCheckIndexController extends BaseController {
	@Autowired
	private ILabSafetyCheckIndexService labSafetyCheckIndexService;

	/**
	 * 查询安全检查模板列表
	 * 公共资源查询使用，不设权限
	 */
	//@PreAuthorize("@ss.hasPermi('labsafety:labsafetyCheckIndex:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabSafetyCheckIndex labSafetyCheckIndex) {
		startPage();
		List<LabSafetyCheckIndex> list = labSafetyCheckIndexService.selectLabSafetyCheckIndexList(labSafetyCheckIndex);
		return getDataTable(list);
	}

	/**
	 * 导出安全检查模板列表
	 */
	// @PreAuthorize("@ss.hasPermi('labsafety:labsafetyCheckIndex:export')")
	/*@Log(title = "安全检查模板", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(LabSafetyCheckIndex labSafetyCheckIndex) {
		List<LabSafetyCheckIndex> list = labSafetyCheckIndexService.selectLabSafetyCheckIndexList(labSafetyCheckIndex);
		ExcelUtil<LabSafetyCheckIndex> util = new ExcelUtil<LabSafetyCheckIndex>(LabSafetyCheckIndex.class);
		return util.exportExcel(list, "labsafetyCheckIndex");
	}*/

	/**
	 * 获取安全检查模板详细信息
	 */
	@PreAuthorize("@ss.hasPermi('labsafety:labsafetyCheckIndex:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult.success(labSafetyCheckIndexService.selectLabSafetyCheckIndexById(id));
	}

	/**
	 * 新增安全检查模板
	 */
	@PreAuthorize("@ss.hasPermi('labsafety:labsafetyCheckIndex:edit')")
	@Log(title = "安全检查模板", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabSafetyCheckIndex labSafetyCheckIndex) {
		return toAjax(labSafetyCheckIndexService.insertLabSafetyCheckIndex(labSafetyCheckIndex));
	}

	/**
	 * 修改安全检查模板
	 */
	@PreAuthorize("@ss.hasPermi('labsafety:labsafetyCheckIndex:edit')")
	@Log(title = "安全检查模板", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabSafetyCheckIndex labSafetyCheckIndex) {
		return toAjax(labSafetyCheckIndexService.updateLabSafetyCheckIndex(labSafetyCheckIndex));
	}

	/**
	 * 删除安全检查模板
	 */
	@PreAuthorize("@ss.hasPermi('labsafety:labsafetyCheckIndex:edit')")
	@Log(title = "安全检查模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long[] ids) {
		return toAjax(labSafetyCheckIndexService.deleteLabSafetyCheckIndexByIds(ids));
	}
}
